<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="box">
        <p>页面在
            <span id="Os">3</span>
            s后跳转
        </p>
        <button id="btn" onclick="stop()">停止</button>
    </div>
    <script>
        var Os=document.getElementById("Os");
        var num=3;
        var timer=setInterval(function () {
            num--;
            Os.innerText=num;
            if(num==0){
                window.location.href="https://www.sogou.com/";
            }
        },1000)
        function stop() {
            clearInterval(timer);
        }
    </script>
</body>
</html>